import wx
from inspect import *
from pyeasyaccept.commom.Configuration import Configuration

class ButtonCmdsPanel(wx.ScrolledWindow):
    """
    It's a panel which contains commands of a given Facade. Each button
    represents a command.
     
    @author: Danilo Torres
    """
    
    INITIAL_BUTTON_ID = 0
#    
    def __init__(self, parent, id):
         """
         Initializes the panel.
         """
         wx.ScrolledWindow.__init__(self, parent, id, size=wx.Size(130,300))
         self.sizer = wx.GridBagSizer()
         self.setScrollBars()
         self.resetButtonID()
         self.SetBackgroundColour(Configuration.BACKGROUND_COLOUR)
         self.SetAutoLayout(True)
         self.SetSizer(self.sizer)
         self.listeners = []
         
    def setScrollBars(self):
         self.unit = 20
         width, height = self.GetSizeTuple()
         self.SetScrollbars(self.unit, self.unit, width/self.unit, height/self.unit)
        
        
    def addButtonPressedListener(self, listener):
        """
        Adds a listener to this panel. Whenever a button is pressed, an
        event is sent to the listener.
        The ButtonPressedListener must implement the 
        method: buttonPressed(cmd, args)
        """
        self.listeners.append(listener)
                
    def resetButtonID(self):
        """
        Resets the button ID.
        """
        self.lastButtonID = self.INITIAL_BUTTON_ID
        
    def incrementLastButtonID(self):
        """
        Increments the last button ID.
        """
        self.lastButtonID += 1 